package org.wu.reggie.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.wu.reggie.entity.AddressBook;

import java.util.List;

public interface AddressBookMapper {

    @Select("select * from address_book where user_id = #{userId}")
    List<AddressBook> queryAddressList(Long userId);

    @Insert("insert into address_book(user_id,consignee,phone,sex,detail,label,create_time,update_time,create_user,update_user)" +
            "values (#{userId},#{consignee},#{phone},#{sex},#{detail},#{label},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(AddressBook addressBook);

    @Select("select * from address_book where user_id = #{userId} and is_default = 1")
    AddressBook getDefaultAddress(Long currentId);

    @Select("select * from address_book where id = #{id}")
    AddressBook getById(Long id);
}
